# -*- coding=utf-8 -*-
from nonebot import on_command, CommandSession
from .covid_go_get import covid_ask
from .covid_cn import 获取省份疫情


@on_command('covgo',aliases=['新冠全球'])
async def _covgo(session:CommandSession):
    country = session.get('country',prompt='请输入标准的国家名')
    ret = covid_ask(country)
    await session.finish(str(ret))

@_covgo.args_parser
async def _(session: CommandSession):
    stripped_arg = session.current_arg_text.strip()
    
    if session.is_first_run:
        if stripped_arg:
            session.state['country'] = stripped_arg
        return
        
        if not stripped_arg:
            session.pause('不能为空,重新输入')
        
    session.state[session.current_key] = stripped_arg


# ============================================================== #



@on_command('covcn',aliases=['国内疫情'])
async def _covcn(session:CommandSession):
    province = session.get('province',prompt='请输入省份名称')
    ret = 获取省份疫情(province)
    await session.finish(ret)




@_covcn.args_parser
async def _(session:CommandSession):
    stripped_arg = session.current_arg_text.strip()

    if session.is_first_run:
        if stripped_arg:
            session.state['proovince'] = stripped_arg
        return

    if stripped_arg == 'bye':
        session.finish('bye')

    if not stripped_arg:
        session.pause('请重新输入,或输入"bye"来结束会话')
    
    session.state[session.current_key] = stripped_arg